<template>
  <div id="App">
    姓名：<input v-model="formData.name" type="text"><br><br>
    年龄：<input v-model="formData.age" type="text"><br><br>
    身高：<input v-model="formData.height" type="text">(米)<br><br>
    体重：<input v-model="formData.weight" type="text">(公斤)<br><br>
    病史：<input v-model="formData.history" type="text"><br><br>
    <button @click="fun">诊断</button>
    <p v-show="xianyin">患者 {{ formData.name }} 的诊断结果：{{ normal }}</p>
  </div>
</template>

<script>

export default {
  data() {
    return {
      formData: {},
      normal: '',
      xianyin: false
    }
  },
  methods: {
    fun() {
      let Bmi = this.formData.weight / Math.pow(this.formData.height, 2);
      if (Bmi <= 18.5) {
        this.normal = "体重过轻";
      } else if (Bmi > 18.5 && Bmi <= 24.9) {
        this.normal = "正常";
      } else if (Bmi > 24.9 && Bmi <= 29.9) {
        this.normal = "体重过重";
      } else {
        this.normal = "肥胖";
      }
      this.xianyin = !this.xianyin
    },

  }
}
</script>

<style></style>